//
//  MainTabBarController.m
//  Code
//
//  Created by 韩东 on 17/10/24.
//  Copyright © 2017年 HD. All rights reserved.
//

#import "MainTabBarController.h"
#import "MainNavigationController.h"

@interface MainTabBarController ()

@end

@implementation MainTabBarController{
    
}


- (void)viewDidLoad {
    [super viewDidLoad];
    self.tabBar.backgroundColor = [UIColor whiteColor];
    UIViewController *homeController = [self controllerWith:@"HomeViewController" title:@"将军令" imageName:@"Home"];
    UIViewController *messageController = [self controllerWith:@"MessageViewController"title:@"公告" imageName:@"Notice"];
    
    
    UIViewController *mineController = [self controllerWith:@"MineViewController" title:@"我的" imageName:@"Me"];
    
    self.viewControllers=@[homeController,messageController,mineController];

}



-(UIViewController *)controllerWith:(NSString *)className title:(NSString *)title imageName:(NSString *)imageName{
    Class clz = NSClassFromString(className);
    UIViewController *controller = [[clz alloc]init];
    
    return [self controller:controller WithTitle:title imageName:imageName];
}
- (UIViewController *)controller:(UIViewController *)controller WithTitle:(NSString *)title imageName:(NSString *)imageName{
    
    controller.tabBarItem.title = title;
    controller.tabBarItem.image = [[UIImage imageNamed:imageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    controller.tabBarItem.selectedImage = [[UIImage imageNamed:[NSString stringWithFormat:@"%@_Sel",imageName]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    MainNavigationController *navController = [[MainNavigationController alloc]initWithRootViewController:controller];
    
    
    return navController;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
    
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
